var code;
var cant;
var xmlhttp = new getXMLObject(); // xmlhttp holds the ajax object
function ajaxFunction(input) {
	code = input.name;
	cant = input.value;
	if (xmlhttp) {
		xmlhttp.open("GET", "/Kasabisu/KAjax?v=" + cant + "&id=" + code, true);
		xmlhttp.onreadystatechange = handleServerResponse;		
		xmlhttp.send(null);
	}
}
function handleServerResponse() {
	if (xmlhttp.readyState == 4) {
		if (xmlhttp.status == 200) {
			// inH valoare element
			var eValue = document.getElementById('inH' + code).value;
			// total lista
			var total = document.getElementById('sListTotal').innerHTML;
			// old value
			var old = document.getElementById('oldV' + code).value;

			var diffCant = cant - old;
			var diffVal = diffCant * eValue;
			
			document.getElementById('oldV' + code).value = cant;
			
			total = (total * 1) + (diffVal * 1);
			total = total.toFixed(1);
			document.getElementById('sListTotal').innerHTML = total;
			// total pe linie
			var sval = document.getElementById('sValue' + code);
			var stot = document.getElementById('sTotal' + code);
			var lineTotal = sval.innerHTML * 1.0 * cant;
			lineTotal = lineTotal.toFixed(1);
			stot.innerHTML = lineTotal;
		}
	}
}